#pragma once
#include "CXcpObjectBase.h"
#include "IPALDownloadResponseCallback.h"
#include "CXcpObjectThreadSafeAddRefPolicy.h"

class ImageCache;

class ImageCacheDownloadCallback :
	public CXcpObjectBase<IPALDownloadResponseCallback,CXcpObjectThreadSafeAddRefPolicy>
{

public: 
	static HRESULT Create(ImageCache * pCache, ImageCacheDownloadCallback * * ppDownloadCallback);
	virtual HRESULT MakeSeekable();
	virtual XUINT32 AcceptsBackgroundThreadCallbacks();
	virtual HRESULT GotResponse(struct IPALDownloadResponse * pResponse, HRESULT status);
	virtual HRESULT GotStream(struct IPALStream * pStream, CXString * pMimeType, XINT32 redirected, CXString * pFinalUrl, CXString * pHeaders);
	virtual HRESULT GotData(XUINT64 size, XUINT64 totalSize);
	virtual HRESULT EndData(XUINT64 uiSize, XUINT64 uiTotalSize);

protected: 
	ImageCacheDownloadCallback();
	virtual ~ImageCacheDownloadCallback();
	HRESULT Initialize(ImageCache * pCache);
	ImageCache * m_pCache;

};


